import React, { useEffect } from 'react';
import logo from './logo.svg';
import './App.css';
import { getGreetContracthello } from 'utils'
import { ethers } from 'ethers';
import { useWeb3React } from '@web3-react/core'
import {  InjectConnect } from 'utils'
import Test from 'views/test'
import Test1, { Test3 } from 'views/test2'
import { useAddEthereumChain } from 'hooks';
import { useTranslation } from 'react-i18next';
function App() {
  const { activate, account, chainId, library, active, connector } = useWeb3React<ethers.providers.Web3Provider>()
  console.log("chainId", chainId)
  console.log("library", library)
  // account 账户
  /*  console.log("account", account)
   // 链id
   console.log("chainId", chainId)
   // library 为Provider 中函数执行返回的Web3Provider
   console.log("library", library)
   // 是否已激活
   console.log("active", active)
   // 连接器
   console.log("connector", connector) */
  const addEthereumChain = useAddEthereumChain()
 
  const greet=async ()=>{
    console.log(getGreetContracthello)
    const contract=getGreetContracthello()
    const res=await contract.greet()
    console.log("greet",res)
    debugger
    /*  const contract=getGreetContracthello()
     console.log(contract) */
    /*const res=await contract.greet()
    console.log("greet",res)  */
  }
  useEffect(() => {
    const actives = async () => {
      try {
        // 激活
        await activate(InjectConnect,undefined,true)
      } catch (ex: any) {
        console.log("error", ex)
      }
    }
    actives()

  }, [])
  const {t} =useTranslation()
  return (
    <div className="App">
      <button onClick={greet}>获取年龄</button>
    </div>
  );
}

export default App;
